﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace TradeMeSDK
{
    public class SearchResults
    {
        public int TotalCount { get; set; }
        public int Page { get; set; }
        public int PageSize { get; set; }
        public List<ListedItemDetail> List { get; set; }
        public string DidYouMean { get; set; }
        public List<FoundCategory> FoundCategories { get; set; }
    }

    public class JobResults
    {
        public int TotalCount { get; set; }
        public int Page { get; set; }
        public int PageSize { get; set; }
        public List<JobResult> List { get; set; }
        public string DidYouMean { get; set; }
        public List<FoundCategory> FoundCategories { get; set; }
    }

    public class JobResult
    {
        public int ListingId { get; set; }
        public string Title { get; set; }
        public string Category { get; set; }
        public double StartPrice { get; set; }
        public double BuyNowPrice { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public bool IsFeatured { get; set; }
        public bool HasGallery { get; set; }
        public bool IsBold { get; set; }
        public bool IsHighlighted { get; set; }
        public bool HasHomePageFeature { get; set; }
        public bool HasExtraPhotos { get; set; }
        public bool HasScheduledEndDate { get; set; }
        public int BidderAndWatchers { get; set; }
        public int MaxBidAmount { get; set; }
        public DateTime AsAt { get; set; }
        public string CategoryPath { get; set; }
        public string PictureHref { get; set; }
        public int PhotoId { get; set; }
        public bool HasPayNow { get; set; }
        public bool IsNew { get; set; }
        public int RegionId { get; set; }
        public string Region { get; set; }
        public int SuburbId { get; set; }
        public string Suburb { get; set; }
        public int BidCount { get; set; }
        public int ViewCount { get; set; }
        public bool IsReserveMet { get; set; }
        public bool HasReserve { get; set; }
        public bool HasBuyNow { get; set; }
        public DateTime NoteDate { get; set; }
        public string CategoryName { get; set; }
        public string ReserveState { get; set; }
        public bool IsClassified { get; set; }
        public bool IsOnWatchList { get; set; }

        public string District { get; set; }
        public string JobType { get; set; }
        public string PayBenefits { get; set; }
        public string Reference { get; set; }
        public string ApplicationDetails { get; set; }
        public bool IsWorkPermitRequired { get; set; }
        public string Instructions { get; set; }
        // Listed
        // Keywords
        // JobCategory
        // JobSubcategory
        public string Company { get; set; }
        public string JobLocation { get; set; }
        public string ContractLength { get; set; }
        public string PayType { get; set; }
        public string JobPackId { get; set; }
        public string Body { get; set; }
        public Agency Agency { get; set; }

    }

    public class FoundCategory
    {
        public int Count { get; set; }
        public string Category { get; set; }
        public string Name { get; set; }
    }

    /// <summary>
    /// The XMLInclude attribute is required until the full C#4 compiler works for WP7
    /// </summary>

    [XmlInclude(typeof(SearchGeneralCriteria))]
    [XmlInclude(typeof(SearchUsedMotorsCriteria))]
    [XmlInclude(typeof(SearchNewMotorsCriteria))]
    [XmlInclude(typeof(SearchBoatsCriteria))]
    [XmlInclude(typeof(SearchMotorBikesCriteria))]
    [XmlInclude(typeof(SearchResidentialCriteria))]
    [XmlInclude(typeof(SearchCommercialCriteria))]
    [XmlInclude(typeof(SearchRuralCriteria))]
    [XmlInclude(typeof(SearchLifestyleCriteria))]
    [XmlInclude(typeof(SearchFlatmatesCriteria))]
    public class SearchCriteria
    {
        /// <summary>
        /// One or more keywords to use in a search query
        /// </summary>
        public string SearchString { get; set; }

        /// <summary>
        /// Restricts search results to items from sellers located in the specified region
        /// </summary>
        public int Region { get; set; }

        /// <summary>
        /// Default, TitleAsc, ExpiryAsc, ExpiryDesc, PriceAsc, PriceDesc, BidsMost, BuyNowAsc, BuyNowDesc
        /// </summary>
        public string SortOrder { get; set; }

        /// <summary>
        /// Return only listings started from this date.
        /// </summary>
        //public DateTime StartDate { get; set; }

        /// <summary>
        /// Page Number
        /// </summary>
        public int PageNumber { get; set; }

        /// <summary>
        /// Number of rows per page. 
        /// </summary>
        public int Rows { get; set; }
    }

    public class SearchGeneralCriteria : SearchCriteria
    {
        /// <summary>
        /// Specifies the category in which you want to perform the search (e.g. “0124-3419-” for Electronics & photography > Camera accessories)
        /// </summary>
        public string Category { get; set; }

        /// <summary>
        /// Return only listings with BuyNow price. 
        /// </summary>
        public bool OnlyBuyNow { get; set; }

        /// <summary>
        /// Return only listings with PayNow. 
        /// </summary>
        public bool OnlyPayNow { get; set; }

        /// <summary>
        /// Filter listings by condition. Applicable values are “All” which is the default and “New” which filters out used items.
        /// </summary>
        public string Condition { get; set; }

        /// <summary>
        /// Returns only listing from specified member ID.
        /// </summary>
        public int MemberId { get; set; }
    }

    public class SearchUsedMotorsCriteria : SearchCriteria
    {
        public decimal MinPrice { get; set; }
        public decimal MaxPrice { get; set; }
        public string Make { get; set; }
        public string Model { get; set; }
        public string BodyStyle { get; set; }
        public int MinDoors { get; set; }
        public int MaxDoors { get; set; }
        public string Transmission { get; set; }
        public int MinYear { get; set; }
        public int MaxYear { get; set; }
        public int MinEngineSize { get; set; }
        public int MaxEngineSize { get; set; }
        public int MinOdometer { get; set; }
        public int MaxOdometer { get; set; }
        public string ListingType { get; set; }
    }

    public class SearchNewMotorsCriteria : SearchCriteria
    {
        public decimal MinPrice { get; set; }
        public decimal MaxPrice { get; set; }
        public string Make { get; set; }
        public string Model { get; set; }
        public string BodyStyle { get; set; }
    }

    public class SearchBoatsCriteria : SearchCriteria
    {
        public decimal MinPrice { get; set; }
        public decimal MaxPrice { get; set; }
        public string Type { get; set; }
        public int MinLength { get; set; }
        public int MaxLength { get; set; }
    }

    public class SearchMotorBikesCriteria : SearchCriteria
    {
        public decimal MinPrice { get; set; }
        public decimal MaxPrice { get; set; }
        public string Make { get; set; }
        public string Type { get; set; }
        public int MinYear { get; set; }
        public int MaxYear { get; set; }
        public int MinEngineSize { get; set; }
        public int MaxEngineSize { get; set; }
    }

    public class SearchJobsCriteria : SearchCriteria
    {
        public decimal MinSalary { get; set; }
        public decimal MaxSalary { get; set; }
        public int District { get; set; }

        /// <summary>
        /// Type of position. Applicable values: CT (contract), PT (permanent), FT (full time)
        /// </summary>
        public string PositionType { get; set; }
        public int Category { get; set; }
        public int SubCategory { get; set; }
    }


    public class SearchResidentialCriteria : SearchCriteria
    {
        public int District { get; set; }
        public int Suburb { get; set; }
        public int MinPrice { get; set; }       // Minimum property price. 
        public int MaxPrice { get; set; }       // Maximum property price. 
        public int MinBedrooms { get; set; }    // Minimum number of bedrooms. 
        public int MaxBedrooms { get; set; }    // Maximum number of bedrooms. 
        public int MinBathrooms { get; set; }   // Minimum number of bathrooms. 
        public int MaxBathrooms { get; set; }   // Maximum number of bathrooms. 
        public int MinArea { get; set; }        // Minimum floor area in square meters. 
        public int MaxArea { get; set; }        // Maximum square area in square meters. 
        public int MinLandArea { get; set; }    // Minimum land area in square meters. 
        public int MaxLandArea { get; set; }    // Maximum land area in square meters. 
        public string PropertyType { get; set; }    // Any (default), Apartment, House, Section, Townhouse, Unit, Other, Villa 
        public bool AdjacentSuburbs { get; set; }   // Indicates whether the search should include listings in adjacent suburbs. 
    }

    public class SearchCommercialCriteria : SearchCriteria
    {
        public int District { get; set; }
        public int Suburb { get; set; }
        public int MinPrice { get; set; }       // Minimum property price. 
        public int MaxPrice { get; set; }       // Maximum property price. 
        public int MinBedrooms { get; set; }    // Minimum number of bedrooms. 
        public int MaxBedrooms { get; set; }    // Maximum number of bedrooms. 
        public int MinBathrooms { get; set; }   // Minimum number of bathrooms. 
        public int MaxBathrooms { get; set; }   // Maximum number of bathrooms. 
        public int MinArea { get; set; }        // Minimum floor area in square meters. 
        public int MaxArea { get; set; }        // Maximum square area in square meters. 
        public int MinLandArea { get; set; }    // Minimum land area in square meters. 
        public int MaxLandArea { get; set; }    // Maximum land area in square meters. 
        public bool AdjacentSuburbs { get; set; }   // Indicates whether the search should include listings in adjacent suburbs. 
        public string Usage { get; set; }       // Any (default), CarPark, DevelopmentSite, HotelLeisure, Industrial, Office, Retail, Tourism
    }

    public class SearchRuralCriteria : SearchCriteria
    {
        public int District { get; set; }
        public int Suburb { get; set; }
        public int MinPrice { get; set; }       // Minimum property price. 
        public int MaxPrice { get; set; }       // Maximum property price. 
        public int MinLandArea { get; set; }    // Minimum land area in square meters. 
        public int MaxLandArea { get; set; }    // Maximum land area in square meters. 
        public string Usage { get; set; }       // Any (default), BareLand, Cropping, Dairy, Deer, Forestry, HighCountry, Horticulture, Mixed, SheepBeef
    }

    public class SearchLifestyleCriteria : SearchCriteria
    {
        public int District { get; set; }
        public int Suburb { get; set; }
        public int MinPrice { get; set; }       // Minimum property price. 
        public int MaxPrice { get; set; }       // Maximum property price. 
        public int MinBedrooms { get; set; }    // Minimum number of bedrooms. 
        public int MaxBedrooms { get; set; }    // Maximum number of bedrooms. 
        public int MinBathrooms { get; set; }   // Minimum number of bathrooms. 
        public int MaxBathrooms { get; set; }   // Maximum number of bathrooms. 
        public int MinArea { get; set; }        // Minimum floor area in square meters. 
        public int MaxArea { get; set; }        // Maximum square area in square meters. 
        public int MinLandArea { get; set; }    // Minimum land area in square meters. 
        public int MaxLandArea { get; set; }    // Maximum land area in square meters. 
        public string PropertyType { get; set; }    // Any (default), Dwelling, Bare land
        public bool AdjacentSuburbs { get; set; }   // Indicates whether the search should include listings in adjacent suburbs. 
        public string Usage { get; set; }       // Any (default), Dwelling
    }

    public class SearchFlatmatesCriteria : SearchCriteria
    {
        public int District { get; set; }
        public int Suburb { get; set; }
        public int MinPrice { get; set; }       // Minimum property price. 
        public int MaxPrice { get; set; }       // Maximum property price. 
    }

}
